#include "Headers.h"
#include "TimeManager.h"


CTimeManager::CTimeManager(void)
{
}


CTimeManager::~CTimeManager(void)
{
}

void CTimeManager::Initialize()
{
	m_dwWorldTime = 0;
	m_dwElapsedTime = 0;
	m_dwFps = 0;
	m_dwFrame = 0;

	m_dwFpsLimitTime = 0;
	m_dwAddFps = 0;

	m_dwCurrentTime = GetTickCount();
	m_dwLastTime = m_dwCurrentTime;
}

void CTimeManager::Uninitialize()
{
}

void CTimeManager::Process()
{
	m_dwLastTime = m_dwCurrentTime;
	m_dwCurrentTime = GetTickCount();

	m_dwElapsedTime = m_dwCurrentTime - m_dwLastTime;
	m_dwWorldTime +=m_dwElapsedTime;
	m_dwFrame++;

	if(m_dwFpsLimitTime <= m_dwWorldTime)
	{
		m_dwFpsLimitTime = m_dwWorldTime + 1000;
		m_dwFps = m_dwAddFps;
		m_dwAddFps = 0;

		LPWSTR Message = new TCHAR[100];
		wsprintf(Message, TEXT("Frame : %d"), (int)m_dwFps);
		SetWindowText(g_hWndMain, Message);
		SAFE_DELETE_ARRAY(Message);

	}
	else
	{
		++m_dwAddFps;
	}
}